﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace States
{
    public class City
    {
        // Attribute Data members
        private String cityCode;
        public String CityCode
        {
            get { return cityCode; }
            set { cityCode = value; }
        }

        private String cityName;
        public String CityName
        {
            get { return cityName; }
            set { cityName = value; }
        }

        // Relationship Data Members
        // State city lelongs to
        private State state;
        public State State
        {
            get { return state; }
            set { state = value; }
        }

        public City()
        {
        }

        public City(string sText)
        {
            if (!string.IsNullOrEmpty(sText))
            {
                int nIndex = sText.IndexOf('(');
                if (nIndex > -1)
                {
                    CityName = sText.Substring(0, nIndex);
                    CityCode = sText.Substring(nIndex + 1, sText.Length - nIndex - 2);
                }
            }
        }

        public override string ToString()
        {
            return string.Format("Cite Code:'{0}' - Name:'{1}'", CityCode, CityName);
        }
    }
}
